home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / gfx / x11 / Xincludes_930531.lha / os-include_x11.lha / os-include / X11 / xpm.h < prev    next >
C/C++ Source or Header  |  1993-05-07  |  9KB  |  281 lines

  1. /* Copyright 1990-93 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * xpm.h:                                                                      *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Include file                                                               *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #ifndef XPM_h
  12. #define XPM_h
  13.  
  14. #ifdef VMS
  15. #include "decw$include:Xlib.h"
  16. #include "decw$include:Xutil.h"
  17. #else
  18. #include <X11/Xlib.h>
  19. #include <X11/Xutil.h>
  20. #endif
  21.  
  22. /* let's define Pixel if it is not done yet */
  23. #ifndef _XtIntrinsic_h
  24. typedef unsigned long Pixel;        /* Index into colormap */
  25. #endif
  26.  
  27. /* Return ErrorStatus codes:
  28.  * null     if full success
  29.  * positive if partial success
  30.  * negative if failure
  31.  */
  32.  
  33. #define XpmColorError    1
  34. #define XpmSuccess       0
  35. #define XpmOpenFailed   -1
  36. #define XpmFileInvalid  -2
  37. #define XpmNoMemory     -3
  38. #define XpmColorFailed  -4
  39.  
  40. /* the following should help people wanting to use their own functions */
  41. #define XpmFree(ptr) free(ptr)
  42.  
  43. typedef struct {
  44.     char *name;                /* Symbolic color name */
  45.     char *value;            /* Color value */
  46.     Pixel pixel;            /* Color pixel */
  47. }      XpmColorSymbol;
  48.  
  49. typedef struct {
  50.     char *name;                /* name of the extension */
  51.     unsigned int nlines;        /* number of lines in this extension */
  52.     char **lines;            /* pointer to the extension array of
  53.                      * strings */
  54. }      XpmExtension;
  55.  
  56. typedef struct {
  57.     unsigned long valuemask;        /* Specifies which attributes are
  58.                      * defined */
  59.  
  60.     Visual *visual;            /* Specifies the visual to use */
  61.     Colormap colormap;            /* Specifies the colormap to use */
  62.     unsigned int depth;            /* Specifies the depth */
  63.     unsigned int width;            /* Returns the width of the created
  64.                      * pixmap */
  65.     unsigned int height;        /* Returns the height of the created
  66.                      * pixmap */
  67.     unsigned int x_hotspot;        /* Returns the x hotspot's
  68.                      * coordinate */
  69.     unsigned int y_hotspot;        /* Returns the y hotspot's
  70.                      * coordinate */
  71.     unsigned int cpp;            /* Specifies the number of char per
  72.                      * pixel */
  73.     Pixel *pixels;            /* List of used color pixels */
  74.     unsigned int npixels;        /* Number of pixels */
  75.     XpmColorSymbol *colorsymbols;    /* Array of color symbols to
  76.                      * override */
  77.     unsigned int numsymbols;        /* Number of symbols */
  78.     char *rgb_fname;            /* RGB text file name */
  79.     unsigned int nextensions;        /* number of extensions */
  80.     XpmExtension *extensions;        /* pointer to array of extensions */
  81.  
  82.     /* Infos */
  83.     unsigned int ncolors;        /* Number of colors */
  84.     char ***colorTable;            /* Color table pointer */
  85.     char *hints_cmt;            /* Comment of the hints section */
  86.     char *colors_cmt;            /* Comment of the colors section */
  87.     char *pixels_cmt;            /* Comment of the pixels section */
  88.     unsigned int mask_pixel;        /* Transparent pixel's color table
  89.                      * index */
  90.     /* Color Allocation Directives */
  91.     unsigned int exactColors;        /* Only use exact colors for visual */
  92.     unsigned int closeness;        /* Allowable RGB deviation */
  93.     unsigned int red_closeness;        /* Allowable red deviation */
  94.     unsigned int green_closeness;    /* Allowable green deviation */
  95.     unsigned int blue_closeness;    /* Allowable blue deviation */
  96.     int color_key;            /* Use colors from this color set */
  97.  
  98. }      XpmAttributes;
  99.  
  100. /* Xpm attribute value masks bits */
  101. #define XpmVisual       (1L<<0)
  102. #define XpmColormap       (1L<<1)
  103. #define XpmDepth       (1L<<2)
  104. #define XpmSize           (1L<<3)    /* width & height */
  105. #define XpmHotspot       (1L<<4)    /* x_hotspot & y_hotspot */
  106. #define XpmCharsPerPixel   (1L<<5)
  107. #define XpmColorSymbols       (1L<<6)
  108. #define XpmRgbFilename       (1L<<7)
  109. #define XpmInfos       (1L<<8)    /* all infos members */
  110. #define XpmExtensions      (1L<<10)
  111.  
  112. #define XpmReturnPixels       (1L<<9)
  113. #define XpmReturnInfos       XpmInfos
  114. #define XpmReturnExtensions XpmExtensions
  115.  
  116. #define XpmExactColors     (1L<<11)
  117. #define XpmCloseness       (1L<<12)
  118. #define XpmRGBCloseness       (1L<<13)
  119. #define XpmColorKey       (1L<<14)
  120.  
  121. /*
  122.  * color keys for visual type, they must match those defined in xpmP.h
  123.  */
  124. #define XPM_MONO    2
  125. #define XPM_GREY4    3
  126. #define XPM_GRAY4    3
  127. #define XPM_GREY     4
  128. #define XPM_GRAY     4
  129. #define XPM_COLOR    5
  130.  
  131. /*
  132.  * minimal portability layer between ansi and KR C
  133.  */
  134.  
  135. /* forward declaration of functions with prototypes */
  136.  
  137. #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  138.  /* ANSI || C++ */
  139. #define FUNC(f, t, p) extern t f p
  140. #define LFUNC(f, t, p) static t f p
  141. #else                    /* K&R */
  142. #define FUNC(f, t, p) extern t f()
  143. #define LFUNC(f, t, p) static t f()
  144. #endif                    /* end of K&R */
  145.  
  146.  
  147. /*
  148.  * functions declarations
  149.  */
  150.  
  151. #ifdef __cplusplus
  152. extern "C" {
  153. #endif
  154.  
  155.     FUNC(XpmCreatePixmapFromData, int, (Display *display,
  156.                     Drawable d,
  157.                     char **data,
  158.                     Pixmap *pixmap_return,
  159.                     Pixmap *shapemask_return,
  160.                     XpmAttributes *attributes));
  161.  
  162.     FUNC(XpmCreateDataFromPixmap, int, (Display *display,
  163.                     char ***data_return,
  164.                     Pixmap pixmap,
  165.                     Pixmap shapemask,
  166.                     XpmAttributes *attributes));
  167.  
  168.     FUNC(XpmReadFileToPixmap, int, (Display *display,
  169.                     Drawable d,
  170.                     char *filename,
  171.                     Pixmap *pixmap_return,
  172.                     Pixmap *shapemask_return,
  173.                     XpmAttributes *attributes));
  174.  
  175.     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
  176.                        char *filename,
  177.                        Pixmap pixmap,
  178.                        Pixmap shapemask,
  179.                        XpmAttributes *attributes));
  180.  
  181.     FUNC(XpmCreateImageFromData, int, (Display *display,
  182.                        char **data,
  183.                        XImage **image_return,
  184.                        XImage **shapemask_return,
  185.                        XpmAttributes *attributes));
  186.  
  187.     FUNC(XpmCreateDataFromImage, int, (Display *display,
  188.                        char ***data_return,
  189.                        XImage *image,
  190.                        XImage *shapeimage,
  191.                        XpmAttributes *attributes));
  192.  
  193.     FUNC(XpmReadFileToImage, int, (Display *display,
  194.                    char *filename,
  195.                    XImage **image_return,
  196.                    XImage **shapeimage_return,
  197.                    XpmAttributes *attributes));
  198.  
  199.     FUNC(XpmWriteFileFromImage, int, (Display *display,
  200.                       char *filename,
  201.                       XImage *image,
  202.                       XImage *shapeimage,
  203.                       XpmAttributes *attributes));
  204.  
  205.     FUNC(XpmCreateImageFromBuffer, int, (Display *display,
  206.                      char *buffer,
  207.                      XImage **image_return,
  208.                      XImage **shapemask_return,
  209.                      XpmAttributes *attributes));
  210.  
  211.     FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
  212.                       Drawable d,
  213.                       char *buffer,
  214.                       Pixmap *pixmap_return,
  215.                       Pixmap *shapemask_return,
  216.                       XpmAttributes *attributes));
  217.  
  218.     FUNC(XpmCreateBufferFromImage, int, (Display *display,
  219.                      char **buffer_return,
  220.                      XImage *image,
  221.                      XImage *shapeimage,
  222.                      XpmAttributes *attributes));
  223.  
  224.     FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
  225.                       char **buffer_return,
  226.                       Pixmap pixmap,
  227.                       Pixmap shapemask,
  228.                       XpmAttributes *attributes));
  229.  
  230.     FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
  231.     FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
  232.  
  233.     FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
  234.     FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
  235.  
  236.     FUNC(XpmAttributesSize, int, ());
  237.     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
  238.     FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
  239.                    int nextensions));
  240.  
  241. #ifdef __cplusplus
  242. }                    /* for C++ V2.0 */
  243. #endif
  244.  
  245.  
  246. /* backward compatibility */
  247.  
  248. /* for version 3.0c */
  249. #define XpmPixmapColorError  XpmColorError
  250. #define XpmPixmapSuccess     XpmSuccess
  251. #define XpmPixmapOpenFailed  XpmOpenFailed
  252. #define XpmPixmapFileInvalid XpmFileInvalid
  253. #define XpmPixmapNoMemory    XpmNoMemory
  254. #define XpmPixmapColorFailed XpmColorFailed
  255.  
  256. #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
  257.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  258. #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
  259.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  260.  
  261. /* for version 3.0b */
  262. #define PixmapColorError  XpmColorError
  263. #define PixmapSuccess     XpmSuccess
  264. #define PixmapOpenFailed  XpmOpenFailed
  265. #define PixmapFileInvalid XpmFileInvalid
  266. #define PixmapNoMemory    XpmNoMemory
  267. #define PixmapColorFailed XpmColorFailed
  268.  
  269. #define ColorSymbol XpmColorSymbol
  270.  
  271. #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
  272.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  273. #define XWritePixmapFile(dpy, file, pix, mask, att) \
  274.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  275. #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
  276.     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
  277. #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
  278.     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
  279.  
  280. #endif
  281.